import lejos.nxt.LCD;


public class ArgumentEnumerator {

	private String _args;
	private String _del;
	private String _rest;
	
	public ArgumentEnumerator(String args, String delimiter){
		_del = delimiter;
		_args = args;
		_rest = _args;
	}
	
	public String getNext(){
		if(_rest == null) return null;
		int index = _rest.indexOf(_del);
		if(index == -1) {
			String next = _rest;
			_rest = null;
			return next;
		}
		String next = _rest.substring(0, index);
		if(index == _rest.length() - 1) _rest = "";
		else _rest = _rest.substring(index + 1, _rest.length());
		return next;
	}
	
	public String getFirst() {
		_rest = _args;
		return getNext();
	}
}
